{% extends "announcements/announcements.html" %}

{% block page_link %}
    <link rel="stylesheet" href="../../static/system_setup/css/style.css">
    <link rel="stylesheet" type="text/css" href="../../static/personal_center/css/index.css">
    <link rel="stylesheet" type="text/css" href="../../static/personal_center/css/common.css">
    <script type="text/javascript" src="../../static/personal_center/js/index.js"></script>
{% endblock %}

{% block style %}
    <style>
        .add_class {
            background: #1E90FF;
        }

        .add_background {
            background: #A9A9A9;
        }

        tr {
            height: 35px;
        }

        th {
            text-align: center;
        }

        #daiban_table tr:hover {
            background: #cfcfcf;
        }

        #yiban_table tr:hover {
            background: #cfcfcf;
        }

        tbody td {
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }

        td:first-child, th:first-child {
            position: sticky;
            left: 0; /* 首行永远固定在左侧 */
            z-index: 1;
        }

        thead tr th {
            position: sticky;
            top: 0; /* 列首永远固定在头部  */
            background-color: #E8E8E8;
        }

        th:first-child {
            z-index: 2;
        }

        .li-class {
            list-style: none;
            margin-top: 2%;
            color: #0b0b0b;
            cursor: pointer;
        }

        .top_tag {
            border-bottom: #01AAED solid 2px;
            color: #01AAED;
        }

        .tab_top {
            width: 100px;
            height: 40px;
            line-height: 40px;
            text-align: center;
            display: inline-block;
            cursor: pointer;
        }

    </style>
{% endblock %}

{% block right_content %}
    <div style="display: inline-block;vertical-align: top;width: 100%;height: 100%;">
        <div class="headline" style="background: white;">
            <div id="db" onclick="change_page(this.id)" class="tab_top top_tag">
                我的待办
            </div>
            <div id="yb" onclick="change_page(this.id)" class="tab_top">
                我的已办
            </div>
        </div>

        <div id="my_application" style="width: 100%;height: 95.3%;overflow: auto;background-color: white;">
            <div class="right-box" style="width: 100%;height: 100%;margin-top: 0;">
                <div style="height: 100%;width: 100%;overflow: auto;border-bottom: #cccccc solid 1px;background-color: white;">
                    <section class="grid-main" style="height: 100%;">
                        <table id="main_table"></table>
                    </section>
                </div>
            </div>
        </div>
    </div>

{% endblock %}


{% block script %}
    <script type="text/javascript" src="../../static/administrative/js/layer.js"></script>
    <script>
        window.onload = function () {
            document.getElementById("Announcement-economy").className = "add_class";
            document.getElementById("inform").className = "add-nav-active";
            {#request_data(1, 1);#}

        };

        function change_page(tag_id) {
            var tab = ''
            if (tag_id === 'db') {
                document.getElementById('db').className = 'tab_top top_tag';
                document.getElementById('yb').className = 'tab_top';
                var e = {
                    tab: 'audit'
                };
                table.GM("setQuery", e, (function () {
                    console.log("setQuery执行成功")
                }))
            } else if (tag_id === 'yb') {
                document.getElementById('db').className = 'tab_top';
                document.getElementById('yb').className = 'tab_top top_tag';
                var e = {
                    tab: 'already'
                };
                table.GM("setQuery", e, (function () {
                    console.log("setQuery执行成功")
                }))
            }
        }

        const gridManagerName = "test",
            TYPE_MAP = {1: "HTML/CSS", 2: "nodeJS", 3: "javaScript", 4: "前端鸡汤", 5: "PM Coffee", 6: "前端框架", 7: "前端相关"},
            arg = {
                gridManagerName: "test",
                width: "100%",
                height: "100%",
                autoOrderConfig: {fixed: "left"},
                checkboxConfig: {key: "id", fixed: "left"},
                supportAjaxPage: !0,
                sortMode: "single",
                supportMenu: !0,
                menuHandler: e => (e.unshift({
                    content: "自定义菜单", line: !0, onClick: e => {
                        alert(e)
                    }
                }), e),
                useCellFocus: !0,
                useHideRow: !0,
                supportMoveRow: !0,
                moveRowConfig: {
                    key: "priority", useSingleMode: !0, fixed: "left", handler: (e, t) => {
                        console.log(e, t)
                    }
                },
                disableCache: !1,
                ajaxData: function (e, t) {
                    var local_host = window.location.host;          // 获取当前IP
                    return "/announcements/notice_audit_list"
                },
                exportConfig: {
                    fileName: e => {
                        const t = new Date;
                        let a = `${t.getFullYear()}-${t.getMonth() + 1}-${t.getDate()}`;
                        for (let t in e) a = `${a}-${t}=${e[t]}`;
                        return a
                    }, suffix: "xls"
                },
                ajaxType: "POST",
                responseHandler: e => (e.data.forEach((e => {
                    e.priority = e.id
                 })), e),
                rowRenderHandler: (e, t) => e,
                emptyTemplate: e => `<div style="text-align: center;">${e.query.title ? "搜索为空" : "暂无数据"}</div>`,
                columnData: [
                    {
                        key: "name",
                        text: "公告名称",
                        align: "center",
                        disableMoveRow: !0
                    }, {
                        key: "create_people",
                        text: "发布人",
                        align: "center",
                    }, {
                        key: "company",
                        text: "所属部门",
                        align: "center",
                    }, {
                        key: "announcement_time",
                        text: "发起时间",
                        align: "center",
                    }, {
                        key: "state",
                        text: "状态",
                        align: "center",
                    }, {
                        key: "current_people",
                        text: "审批人",
                        align: "center",
                    }, {
                        key: "action",
                        width: "100px",
                        align: "center",
                        fixed: "right",
                        disableMoveRow: !0,
                        disableRowCheck: !0,
                        text: '<span style="color: red">操作</span>',
                        template: (e, t) => `<a class="plugin-action" id="${t.id}" href="notice_detail.html?id=${t.id}" onclick="">查看</a>`
                    }]
            }, demo1 = {
                initSearch: function () {
                }, initFN: () => {

                }, initGM: function () {
                    new window.GridManager(table, arg, (e => {
                        console.log("渲染完成后的回调函数:", e), console.log(arg.columnData)
                    }))
                }, editRowData: function (e) {
                    window.GridManager.updateRowData("test", "id", {
                        id: window.parseInt(e.getAttribute("data-id")),
                        lastDate: (new Date).getTime()
                    })
                }
            }, table = document.querySelector("#main_table");
        demo1.initSearch(table), demo1.initGM(table), demo1.initFN();

        {#function change_mind(ele_id) {#}
        {#    if (ele_id === "jurisdiction_list") {#}
        {#        document.getElementById("jurisdiction_list").style.display = "inline-block";#}
        {#        document.getElementById("add_jurisdiction").style.display = "none";#}
        {#        document.getElementById("dispatch_detail_tab").className = "tab_top top_tag";#}
        {#        document.getElementById("document_addressee_details_tab").className = "tab_top";#}
        {#    } else {#}
        {#        document.getElementById("add_jurisdiction").style.display = "inline-block";#}
        {#        document.getElementById("jurisdiction_list").style.display = "none";#}
        {#        document.getElementById("dispatch_detail_tab").className = "tab_top";#}
        {#        document.getElementById("document_addressee_details_tab").className = "tab_top top_tag";#}
        {#    }#}
        {# }#}

        {#function request_data(page, type_s) {       // type_s: 1、全部查询，2、查询我的申请，3、查询我的审批#}
        {#    document.getElementById("loading").style.display = "inline-block";#}
        {#    var xhr = new XMLHttpRequest();#}
        {#    var local_host = window.location.host;          // 获取当前IP#}
        {#    xhr.open('get', "/announcements/notice_list?page=" + String(page) + "&type_s=" + String(type_s));#}
        {#xhr.open('get', "http://192.168.2.88:8000/personal-center/bill_group_view");#}
        {#    xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');#}
        {#    xhr.setRequestHeader('Access-Control-Allow-Origin', '*');#}
        {#    xhr.send();#}
        {#    xhr.onreadystatechange = function () {#}
        {#        if (xhr.readyState === 4) {#}
        {#            if (xhr.status === 200) {#}
        {#                document.getElementById("loading").style.display = "none";#}
        {#                var JsonDate = JSON.parse(xhr.responseText);#}
        {#                console.log(JsonDate);#}
        {#                create_table(JsonDate["audit_count"], JsonDate["return_dic"]["audit"]);#}
        {#                create_table1(JsonDate["already_audit_count"], JsonDate["return_dic"]["already_audit"]);#}
        {#                pagenum(JsonDate["audit_count"], page);#}
        {#                pagenum1(JsonDate["already_audit_count"], page);#}
        {#            }#}
        {#        }#}
        {#    };#}
        {# }#}

        {#function create_table(count_nunmber, json_data) {#}
        {#    var t_table = document.getElementById("t_table");#}
        {#    deltr();#}
        {#    if (json_data.length === 0) {#}
        {#        document.getElementById("img-display").style.display = "inline-block";#}
        {#    } else {#}
        {#        document.getElementById("img-display").style.display = "none";#}
        {#    }#}
        {#    for (var i = 0; i < json_data.length; i++) {#}
        {#        var tr = document.createElement("tr");#}
        {#        var td = document.createElement("td");#}
        {#        var td1 = document.createElement("td");#}
        {#        var td2 = document.createElement("td");#}
        {#        var td3 = document.createElement("td");#}
        {#        var td4 = document.createElement("td");#}
        {#        var td5 = document.createElement("td");#}
        {#        var td6 = document.createElement("td");#}
        {#        var state = "";#}
        {#        if (json_data[i]["state"] === "审核中") {#}
        {#            state = "审核中";#}
        {#            td4.innerHTML = "<a href='notice_approve.html?id=" + json_data[i]["id"] + "'>审批</a>";#}
        {#            td4.style.textAlign = "center";#}
        {#        }#}
        {#        if (json_data[i]["state"] === "拒绝") {#}
        {#            state = "退回";#}
        {#            td4.innerHTML = "<a href='notice_change.html?id=" + json_data[i]["id"] + "'>修改</a>";#}
        {#            td4.style.textAlign = "center";#}
        {#        }#}
        {#        if (json_data[i]["state"] === "已审核") {#}
        {#            state = "完结";#}
        {#            td4.innerHTML = "<a href='notice_detail.html?id=" + json_data[i]["id"] + "'>查看</a>";#}
        {#            td4.style.textAlign = "center";#}
        {#        }#}
        {#        td.innerHTML = i + 1;#}
        {#        td.style.textAlign = "center";#}
        {#        td5.innerHTML = json_data[i]["name"];#}
        {#        td5.style.textAlign = "center";#}
        {#        td1.innerHTML = json_data[i]["create_people"];#}
        {#        td1.title = json_data[i]["create_people"];#}
        {#        td1.style.textAlign = "center";#}
        {#        td2.innerHTML = json_data[i]["company"];#}
        {#        td2.title = json_data[i]["company"];#}
        {#        td2.style.textAlign = "center";#}
        {#        td3.innerHTML = state;#}
        {#        td3.title = json_data[i]["state"];#}
        {#        td3.style.textAlign = "center";#}
        {#        td6.innerHTML = json_data[i]["current_people"];#}
        {#        td6.title = json_data[i]["current_people"];#}
        {#        td6.style.textAlign = "center";#}
        {#        td6.style.color = "red";#}
        {#        tr.appendChild(td);#}
        {#        tr.appendChild(td5);#}
        {#        tr.appendChild(td1);#}
        {#        tr.appendChild(td2);#}
        {#        tr.appendChild(td3);#}
        {#        tr.appendChild(td6);#}
        {#        tr.appendChild(td4);#}
        {#        t_table.appendChild(tr);#}
        {#    }#}
        {# }#}

        // 删除列表
        function deltr() {
            var tb = document.getElementById('t_table');
            var rowNum = tb.rows.length;
            for (i = 0; i < rowNum; i++) {
                tb.deleteRow(i);
                rowNum = rowNum - 1;
                i = i - 1;
            }
        }

        {#function create_table1(count_nunmber, json_data) {#}
        {#    var t_table = document.getElementById("t_table1");#}
        {#    deltr1();#}
        {#    if (json_data.length === 0) {#}
        {#        document.getElementById("img-display1").style.display = "inline-block";#}
        {#    } else {#}
        {#        document.getElementById("img-display1").style.display = "none";#}
        {#    }#}
        {#    for (var i = 0; i < json_data.length; i++) {#}
        {#        var tr = document.createElement("tr");#}
        {#        var td = document.createElement("td");#}
        {#        var td1 = document.createElement("td");#}
        {#        var td2 = document.createElement("td");#}
        {#        var td3 = document.createElement("td");#}
        {#        var td4 = document.createElement("td");#}
        {#        var td5 = document.createElement("td");#}
        {#        var td6 = document.createElement("td");#}
        {#        var state = "";#}
        {#        if (json_data[i]["state"] === "审核中") {#}
        {#            state = "审核中";#}
        {#        }#}
        {#        if (json_data[i]["state"] === "拒绝") {#}
        {#            state = "退回";#}
        {#        }#}
        {#        if (json_data[i]["state"] === "已审核") {#}
        {#            state = "完结";#}
        {#        }#}
        {#        td.innerHTML = i + 1;#}
        {#        td.style.textAlign = "center";#}
        {#        td5.innerHTML = json_data[i]["name"];#}
        {#        td5.style.textAlign = "center";#}
        {#        td1.innerHTML = json_data[i]["create_people"];#}
        {#        td1.title = json_data[i]["create_people"];#}
        {#        td1.style.textAlign = "center";#}
        {#        td2.innerHTML = json_data[i]["company"];#}
        {#        td2.title = json_data[i]["company"];#}
        {#        td2.style.textAlign = "center";#}
        {#        td3.innerHTML = state;#}
        {#        td3.title = json_data[i]["state"];#}
        {#        td3.style.textAlign = "center";#}
        {#        td4.innerHTML = "<a href='notice_detail.html?id=" + json_data[i]["id"] + "'>查看</a>";#}
        {#        td4.style.textAlign = "center";#}
        {#        td6.innerHTML = json_data[i]["current_people"];#}
        {#        td6.title = json_data[i]["current_people"];#}
        {#        td6.style.textAlign = "center";#}
        {#        td6.style.color = "red";#}
        {#        tr.appendChild(td);#}
        {#        tr.appendChild(td5);#}
        {#        tr.appendChild(td1);#}
        {#        tr.appendChild(td2);#}
        {#        tr.appendChild(td3);#}
        {#        tr.appendChild(td6);#}
        {#        tr.appendChild(td4);#}
        {#        t_table.appendChild(tr);#}
        {#    }#}
        {# }#}

        // 删除列表
        function deltr1() {
            var tb = document.getElementById('t_table1');
            var rowNum = tb.rows.length;
            for (i = 0; i < rowNum; i++) {
                tb.deleteRow(i);
                rowNum = rowNum - 1;
                i = i - 1;
            }
        }

        // 加载分页条
        function pagenum(dataTotals = 1, page = 1) {
            new myPagination({
                id: 'pagination',
                curPage: page, //初始页码
                pageAmount: 20,  //每页多少条
                dataTotal: dataTotals, //总共多少条数据
                pageTotal: Math.ceil(parseInt(dataTotals, 10) / 20), //总页数
                pageSize: 5, //可选,分页个数
                showPageTotalFlag: true, //是否显示数据统计
                showSkipInputFlag: true, //是否支持跳转
                getPage: function (page) {
                    // var query_type = document.getElementById("query_type").value;
                    // var query_value = document.getElementById("query_value").value;
                    request_data(page, 1);
                }
            });
        }

        // 加载分页条
        function pagenum1(dataTotals = 1, page = 1) {
            new myPagination1({
                id: 'pagination1',
                curPage: page, //初始页码
                pageAmount: 20,  //每页多少条
                dataTotal: dataTotals, //总共多少条数据
                pageTotal: Math.ceil(parseInt(dataTotals, 10) / 20), //总页数
                pageSize: 5, //可选,分页个数
                showPageTotalFlag: true, //是否显示数据统计
                showSkipInputFlag: true, //是否支持跳转
                getPage: function (page) {
                    // var query_type = document.getElementById("query_type").value;
                    // var query_value = document.getElementById("query_value").value;
                    request_data(page, 2);
                }
            });
        }
    </script>
{% endblock %}
